package Hot100;

public class maxArea {
    public static void main(String[] args) {
        int height[] = {2,3,4,5,18,17,6};
        System.out.println(maxArea(height));
    }
    public static int maxArea(int[] height) {
        int left = 0;
        int right = height.length -1;
        int max = 0;
        int area = 0;

        while(left != right){

            if(height[left] >= height[right]){
                area = height[right] * (right - left);
                right--;
            }
            else {
                area = height[left] * (right - left);
                left++;
            }
            if(area > max)
                max = area;

        }

        return max;
    }
}
